﻿#include <graphics.h> 
#include <conio.h>
#include <vector>
#include <string>
#include <ctime>
#pragma comment(lib, "MSIMG32.LIB") 

//对象参数
//1时基单元≈0.01s
//
//友方
//卡米 攻速：150时基单元/子弹 生命值：100 价格：100 攻击力：10 冷却：400
//出货箱 每1500时基单元产生50金币   PS：上方掉落的金币是每750时基单元一个，即2个出货箱的产量=上方自然掉落产量 冷却：400
//刘易斯 攻速：150时基单元/子弹 生命值：100 价格：150 攻击力：7 特殊效果：被命中的敌人速度减少到原来的一半，持续300时基单元 冷却：700
//炸弹 放置80时基单元后爆炸，爆炸范围为水平左右75单位长度，竖直本行与上下两行，伤害50 价格：300 冷却：2000
//塞巴斯 攻速：150时基单元/子弹 生命值：100 价格：200 攻击力：7 冷却：700 可一次攻击一整行的敌人
//罗宾的路障 生命值：5000 价格：100 冷却：1000
//
//敌方
//普通史莱姆 速度：0.5 攻击：3 生命值：50
//蓝色史莱姆 速度：0.5 攻击：3 生命值：100
//红色史莱姆 速度：0.5 攻击：3 生命值：150
//大史莱姆 速度：0.3 攻击：3 生命值：150 被击杀后，将在本行产生2个普通史莱姆，上下两行各产生一个史莱姆（若为最上行或最下行则只会产生3个）
//骷髅 速度：0.4 攻击：3 生命值：50 会扔出骨头来攻击最近的友方单位，伤害30
//幽灵 速度：0.8 攻击：3 生命值：50 有概率随机瞬移到另一行平行的位置
//
//关卡
//第一关：只有开头那5只普通史莱姆，只能放卡米
//第二关：普通史莱姆、蓝色史莱姆、红色史莱姆，可以放卡米、出货箱、刘易斯
//第三关：全部友方 + 全部敌方


int pplchoose = 0;  //当前选中上方友方对象添加区域的flag
bool ischoose = false;
int choosex, choosey;  //选择的地块坐标
int gold;  //金币数
int gencoicnt;  //金币自然生成计数器
int vis[60];  //每个格子有没有已经放友方对象
int level2 = 1;  //第二关是否解锁
int level3 = 1;  //第三关是否解锁
int kill;  //击杀数计数器
int flag;  //页面管理flag
int cartflag = 0;  //动画是否完成播放
int cartcnt = 0;  //控制动画播放进度的计数器
int Camelliawait = 0;  //6个友方对象的冷却计数器
int Saleboxwait = 0;
int Lewiswait = 0;
int Boomwait = 0;
int Sebastianwait = 0;
int Blockwait = 0;
int level2cnt = 0;  //第二关进度计数器
int level3cnt = 0;  //第三关进度计数器
int winflag = 0;  //是否已经完全通关
int pauseflag = 0;  //是否处于暂停状态
int finishcreatenemy;
int generate;

class ImageButton  //按钮类
{
public:
	ImageButton(int X = 0, int Y = 0) : x(X), y(Y) {}
	IMAGE normal;    
	IMAGE hover;     ;   
	int x, y;      
	int width = 0;
	int height = 0;
	bool isactive = false;
	void init()
	{
		this->width = this->normal.getwidth();
		this->height = this->normal.getheight();
	}
};

IMAGE imgPVZ; 
IMAGE waiting;
IMAGE Gold, GoldY, Path, House, Die, Victory, Cartbg, Clint1, Clint1Y, Clint2, Clint2Y, Clint3, Clint3Y, Clint4, Clint4Y, Clint5, Clint5Y, Clint6, Clint6Y, Slime1, Slime1Y, Slime2, Slime2Y, Slime3, Slime3Y, SlimeLOGO, SlimeLOGOY, Slimeslow, SlimeslowY, Metalhead1, Metalhead1Y, Metalhead2, Metalhead2Y, Metalhead3, Metalhead3Y, RedSlime, RedSlimeY, RedSlimeLOGO, RedSlimeLOGOY, RedSlimeSlow, RedSlimeSlowY, BlueSlime, BlueSlimeY, BlueSlimeLOGO, BlueSlimeLOGOY, BlueSlimeSlow, BlueSlimeSlowY, BigSlime, BigSlimeY, BigSlimeLOGO, BigSlimeLOGOY, BigSlimeSlow, BigSlimeSlowY, Skeleton, SkeletonY, SkeletonLOGO, SkeletonLOGOY, SkeletonSlow, SkeletonSlowY, SkeletonBullet, SkeletonBulletY, Ghost, GhostY, GhostLOGO, GhostLOGOY, GhostSlow, GhostSlowY, Skip, Pause, level30n, level30h, Zombie, Camellia, CamelliaY, CamelliaLOGO, CamelliaLOGOY, CamelliaBullet, CamelliaBulletY, CammyPrice, CammyPriceNo, Salebox, SaleboxLOGO, SaleboxPrice, SaleboxPriceNo, Lewis, LewisY, LewisLOGO, LewisLOGOY, LewisBullet, LewisBulletY, LewisPrice, LewisPriceNo, Boom, BoomY, BoomLOGO, BoomLOGOY, BoomPrice, BoomPriceNo, Sebastian, SebastianY, SebastianLOGO, SebastianLOGOY, SebastianBullet, SebastianBulletY, SebastianPrice, SebastianPriceNo, Block, BlockY, BlockLOGO, BlockLOGOY, BlockPrice, BlockPriceNo, Wave, LastWave, Background, PauseButton, Continue;
ImageButton start(100, 500), exi(800, 500), retu(900, 650), level1(100, 300), level20(425, 300), level21(425, 300), level31(750, 300), Help(425, 500);

bool IsMouseInButton(const ImageButton& btn, const MOUSEMSG& msg)  //判断鼠标是否在按钮上
{
	if (!btn.isactive)
	{
		return false;
	}
	return (msg.x >= btn.x && msg.x <= btn.x + btn.width &&
		msg.y >= btn.y && msg.y <= btn.y + btn.height);
}

class people  //友方对象类
{
public:
	people(double X, double Y, int Type, double Health, IMAGE Img, IMAGE ImgY) : x(X), y(Y), type(Type), health(Health), img(Img), imgY(ImgY){}
	double x, y;  //坐标
	int type;  //种类
	IMAGE img, imgY;  //原图和掩码图
	int cnt = 0;  //对象操作计数器
	double health;  //生命值
};

class bullet  //子弹类
{
public:
	bullet(double X, double Y, int Type, double Speed, double Attack, IMAGE Img, IMAGE ImgY) : x(X), y(Y), type(Type), speed(Speed), attack(Attack), img(Img), imgY(ImgY){}
	bullet() {}
	double x, y, speed, attack;  //坐标，速度，攻击伤害
	int type;  //种类
	IMAGE img, imgY;  //原图和掩码图
};

class enemy  //敌方对象类
{
public:
	enemy(double X, double Y, int Type, double Speed, double Attack, double Health, IMAGE Img, IMAGE ImgY, IMAGE Imgslow, IMAGE ImgslowY) : x(X), y(Y), type(Type), speed(Speed), attack(Attack), health(Health), img(Img), imgY(ImgY), imgslow(Imgslow), imgslowY(ImgslowY){}
	double x, y, speed, attack, health;  //坐标，速度，攻击伤害，生命值
	int type;  //种类
	int slowcnt = 0;  //减速计数器
	IMAGE img, imgY, imgslow, imgslowY;  //原图，原图掩码图，减速状态图，减速状态掩码图
	int cnt = 0;  //敌方对象操作计数器
};

class coin  //金币类
{
public:
	coin(double X, double Y, int Type, IMAGE Img, IMAGE ImgY) : x(X), y(Y), type(Type), img(Img), imgY(ImgY){}
	double x, y;  //坐标
	IMAGE img, imgY;  //原图和掩码图
	int type;  //金币生成方式
};

std::vector<people> peoples;
std::vector<enemy> enemies;
std::vector<enemy> enemyaddtem;
std::vector<coin> coins;
bullet bulletsre[1000];  //提前开出一些子弹类对象的存储空间，防止每次都要删除添加存储空间，提高效率
std::vector<bullet> bullets;  //正常情况肯定是同时达不到1000个子弹的...但是保险起见依旧写一个vector，存储超过1000的子弹

int add()  //向开好的1000个空间添加子弹
{
	for (int i = 0; i <= 999; i++)
	{
		if (bulletsre[i].type == 0)
		{
			return i;
		}
	}
	return -1;
}

void cppl(MOUSEMSG msg)  //点击上方的添加友方对象判定区，点击不同区域将添加对象flag设为不同的值
{
	if (msg.x >= 200 && msg.x <= 300 && msg.y >= 0 && msg.y <= 75 && msg.uMsg == WM_LBUTTONDOWN)
	{
		if (gold >= 100 && Camelliawait == 400)
		{
			pplchoose = 1;
		}
	}
	if (msg.x >= 325 && msg.x <= 425 && msg.y >= 0 && msg.y <= 75 && msg.uMsg == WM_LBUTTONDOWN)
	{
		if (gold >= 50 && Saleboxwait == 400)
		{
			pplchoose = 2;
		}
	}
	if (msg.x >= 450 && msg.x <= 550 && msg.y >= 0 && msg.y <= 75 && msg.uMsg == WM_LBUTTONDOWN)
	{
		if (gold >= 150 && Lewiswait == 700)
		{
			pplchoose = 3;
		}
	}
	if (msg.x >= 575 && msg.x <= 675 && msg.y >= 0 && msg.y <= 75 && msg.uMsg == WM_LBUTTONDOWN)
	{
		if (gold >= 300 && Boomwait == 2000)
		{
			pplchoose = 4;
		}
	}
	if (msg.x >= 700 && msg.x <= 800 && msg.y >= 0 && msg.y <= 75 && msg.uMsg == WM_LBUTTONDOWN)
	{
		if (gold >= 200 && Sebastianwait == 700)
		{
			pplchoose = 5;
		}
	}
	if (msg.x >= 825 && msg.x <= 925 && msg.y >= 0 && msg.y <= 75 && msg.uMsg == WM_LBUTTONDOWN)
	{
		if (gold >= 100 && Blockwait == 1000)
		{
			pplchoose = 6;
		}
	}
}

void cgnd(MOUSEMSG msg)  //点击不同地块区域对应到不同坐标，添加友方对象
{
	ischoose = false;
	if (msg.uMsg == WM_LBUTTONDOWN)
	{
		pplchoose = 0;  //无论点击哪里都把添加对象计数器置为0
		if (msg.x > 50 && msg.x < 145 && msg.y > 75 && msg.y < 200)
		{
			if (!vis[1])
			{
				ischoose = true;
				choosex = 72.5;
				choosey = 90;
				vis[1] = 1;  //一个地块只能放一个友方单位
			}
		}
		if (msg.x > 145 && msg.x < 240 && msg.y > 75 && msg.y < 200)
		{
			if (!vis[2])
			{
				ischoose = true;
				choosex = 167.5;
				choosey = 90;
				vis[2] = 1;
			}
		}
		if (msg.x > 240 && msg.x < 335 && msg.y > 75 && msg.y < 200)
		{
			if (!vis[3])
			{
				ischoose = true;
				choosex = 262.5;
				choosey = 90;
				vis[3] = 1;
			}
		}
		if (msg.x > 335 && msg.x < 430 && msg.y > 75 && msg.y < 200)
		{
			if (!vis[4])
			{
				ischoose = true;
				choosex = 357.5;
				choosey = 90;
				vis[4] = 1;
			}
		}
		if (msg.x > 430 && msg.x < 525 && msg.y > 75 && msg.y < 200)
		{
			if (!vis[5])
			{
				ischoose = true;
				choosex = 452.5;
				choosey = 90;
				vis[5] = 1;
			}
		}
		if (msg.x > 525 && msg.x < 620 && msg.y > 75 && msg.y < 200)
		{
			if (!vis[6])
			{
				ischoose = true;
				choosex = 547.5;
				choosey = 90;
				vis[6] = 1;
			}
		}
		if (msg.x > 620 && msg.x < 715 && msg.y > 75 && msg.y < 200)
		{
			if (!vis[7])
			{
				ischoose = true;
				choosex = 642.5;
				choosey = 90;
				vis[7] = 1;
			}
		}
		if (msg.x > 715 && msg.x < 810 && msg.y > 75 && msg.y < 200)
		{
			if (!vis[8])
			{
				ischoose = true;
				choosex = 737.5;
				choosey = 90;
				vis[8] = 1;
			}
		}
		if (msg.x > 810 && msg.x < 905 && msg.y > 75 && msg.y < 200)
		{
			if (!vis[9])
			{
				ischoose = true;
				choosex = 832.5;
				choosey = 90;
				vis[9] = 1;
			}
		}
		if (msg.x > 905 && msg.x < 1000 && msg.y > 75 && msg.y < 200)
		{
			if (!vis[10])
			{
				ischoose = true;
				choosex = 927.5;
				choosey = 90;
				vis[10] = 1;
			}
		}

		if (msg.x > 50 && msg.x < 145 && msg.y > 200 && msg.y < 325)
		{
			if (!vis[11])
			{
				ischoose = true;
				choosex = 72.5;
				choosey = 215;
				vis[11] = 1;
			}
		}
		if (msg.x > 145 && msg.x < 240 && msg.y > 200 && msg.y < 325)
		{
			if (!vis[12])
			{
				ischoose = true;
				choosex = 167.5;
				choosey = 215;
				vis[12] = 1;
			}
		}
		if (msg.x > 240 && msg.x < 335 && msg.y > 200 && msg.y < 325)
		{
			if (!vis[13])
			{
				ischoose = true;
				choosex = 262.5;
				choosey = 215;
				vis[13] = 1;
			}
		}
		if (msg.x > 335 && msg.x < 430 && msg.y > 200 && msg.y < 325)
		{
			if (!vis[14])
			{
				ischoose = true;
				choosex = 357.5;
				choosey = 215;
				vis[14] = 1;
			}
		}
		if (msg.x > 430 && msg.x < 525 && msg.y > 200 && msg.y < 325)
		{
			if (!vis[15])
			{
				ischoose = true;
				choosex = 452.5;
				choosey = 215;
				vis[15] = 1;
			}
		}
		if (msg.x > 525 && msg.x < 620 && msg.y > 200 && msg.y < 325)
		{
			if (!vis[16])
			{
				ischoose = true;
				choosex = 547.5;
				choosey = 215;
				vis[16] = 1;
			}
		}
		if (msg.x > 620 && msg.x < 715 && msg.y > 200 && msg.y < 325)
		{
			if (!vis[17])
			{
				ischoose = true;
				choosex = 642.5;
				choosey = 215;
				vis[17] = 1;
			}
		}
		if (msg.x > 715 && msg.x < 810 && msg.y > 200 && msg.y < 325)
		{
			if (!vis[18])
			{
				ischoose = true;
				choosex = 737.5;
				choosey = 215;
				vis[18] = 1;
			}
		}
		if (msg.x > 810 && msg.x < 905 && msg.y > 200 && msg.y < 325)
		{
			if (!vis[19])
			{
				ischoose = true;
				choosex = 832.5;
				choosey = 215;
				vis[19] = 1;
			}
		}
		if (msg.x > 905 && msg.x < 1000 && msg.y > 200 && msg.y < 325)
		{
			if (!vis[20])
			{
				ischoose = true;
				choosex = 927.5;
				choosey = 215;
				vis[20] = 1;
			}
		}

		if (msg.x > 50 && msg.x < 145 && msg.y > 325 && msg.y < 450)
		{
			if (!vis[21])
			{
				ischoose = true;
				choosex = 72.5;
				choosey = 340;
				vis[21] = 1;
			}
		}
		if (msg.x > 145 && msg.x < 240 && msg.y > 325 && msg.y < 450)
		{
			if (!vis[22])
			{
				ischoose = true;
				choosex = 167.5;
				choosey = 340;
				vis[22] = 1;
			}
		}
		if (msg.x > 240 && msg.x < 335 && msg.y > 325 && msg.y < 450)
		{
			if (!vis[23])
			{
				ischoose = true;
				choosex = 262.5;
				choosey = 340;
				vis[23] = 1;
			}
		}
		if (msg.x > 335 && msg.x < 430 && msg.y > 325 && msg.y < 450)
		{
			if (!vis[24])
			{
				ischoose = true;
				choosex = 357.5;
				choosey = 340;
				vis[24] = 1;
			}
		}
		if (msg.x > 430 && msg.x < 525 && msg.y > 325 && msg.y < 450)
		{
			if (!vis[25])
			{
				ischoose = true;
				choosex = 452.5;
				choosey = 340;
				vis[25] = 1;
			}
		}
		if (msg.x > 525 && msg.x < 620 && msg.y > 325 && msg.y < 450)
		{
			if (!vis[26])
			{
				ischoose = true;
				choosex = 547.5;
				choosey = 340;
				vis[26] = 1;
			}
		}
		if (msg.x > 620 && msg.x < 715 && msg.y > 325 && msg.y < 450)
		{
			if (!vis[27])
			{
				ischoose = true;
				choosex = 642.5;
				choosey = 340;
				vis[27] = 1;
			}
		}
		if (msg.x > 715 && msg.x < 810 && msg.y > 325 && msg.y < 450)
		{
			if (!vis[28])
			{
				ischoose = true;
				choosex = 737.5;
				choosey = 340;
				vis[28] = 1;
			}
		}
		if (msg.x > 810 && msg.x < 905 && msg.y > 325 && msg.y < 450)
		{
			if (!vis[29])
			{
				ischoose = true;
				choosex = 832.5;
				choosey = 340;
				vis[29] = 1;
			}
		}
		if (msg.x > 905 && msg.x < 1000 && msg.y > 325 && msg.y < 450)
		{
			if (!vis[30])
			{
				ischoose = true;
				choosex = 927.5;
				choosey = 340;
				vis[30] = 1;
			}
		}

		if (msg.x > 50 && msg.x < 145 && msg.y > 450 && msg.y < 575)
		{
			if (!vis[31])
			{
				ischoose = true;
				choosex = 72.5;
				choosey = 465;
				vis[31] = 1;
			}
		}
		if (msg.x > 145 && msg.x < 240 && msg.y > 450 && msg.y < 575)
		{
			if (!vis[32])
			{
				ischoose = true;
				choosex = 167.5;
				choosey = 465;
				vis[32] = 1;
			}
		}
		if (msg.x > 240 && msg.x < 335 && msg.y > 450 && msg.y < 575)
		{
			if (!vis[33])
			{
				ischoose = true;
				choosex = 262.5;
				choosey = 465;
				vis[33] = 1;
			}
		}
		if (msg.x > 335 && msg.x < 430 && msg.y > 450 && msg.y < 575)
		{
			if (!vis[34])
			{
				ischoose = true;
				choosex = 357.5;
				choosey = 465;
				vis[34] = 1;
			}
		}
		if (msg.x > 430 && msg.x < 525 && msg.y > 450 && msg.y < 575)
		{
			if (!vis[35])
			{
				ischoose = true;
				choosex = 452.5;
				choosey = 465;
				vis[35] = 1;
			}
		}
		if (msg.x > 525 && msg.x < 620 && msg.y > 450 && msg.y < 575)
		{
			if (!vis[36])
			{
				ischoose = true;
				choosex = 547.5;
				choosey = 465;
				vis[36] = 1;
			}
		}
		if (msg.x > 620 && msg.x < 715 && msg.y > 450 && msg.y < 575)
		{
			if (!vis[37])
			{
				ischoose = true;
				choosex = 642.5;
				choosey = 465;
				vis[37] = 1;
			}
		}
		if (msg.x > 715 && msg.x < 810 && msg.y > 450 && msg.y < 575)
		{
			if (!vis[38])
			{
				ischoose = true;
				choosex = 737.5;
				choosey = 465;
				vis[38] = 1;
			}
		}
		if (msg.x > 810 && msg.x < 905 && msg.y > 450 && msg.y < 575)
		{
			if (!vis[39])
			{
				ischoose = true;
				choosex = 832.5;
				choosey = 465;
				vis[39] = 1;
			}
		}
		if (msg.x > 905 && msg.x < 1000 && msg.y > 450 && msg.y < 575)
		{
			if (!vis[40])
			{
				ischoose = true;
				choosex = 927.5;
				choosey = 465;
				vis[40] = 1;
			}
		}

		if (msg.x > 50 && msg.x < 145 && msg.y > 575 && msg.y < 700)
		{
			if (!vis[41])
			{
				ischoose = true;
				choosex = 72.5;
				choosey = 590;
				vis[41] = 1;
			}
		}
		if (msg.x > 145 && msg.x < 240 && msg.y > 575 && msg.y < 700)
		{
			if (!vis[42])
			{
				ischoose = true;
				choosex = 167.5;
				choosey = 590;
				vis[42] = 1;
			}
		}
		if (msg.x > 240 && msg.x < 335 && msg.y > 575 && msg.y < 700)
		{
			if (!vis[43])
			{
				ischoose = true;
				choosex = 262.5;
				choosey = 590;
				vis[43] = 1;
			}
		}
		if (msg.x > 335 && msg.x < 430 && msg.y > 575 && msg.y < 700)
		{
			if (!vis[44])
			{
				ischoose = true;
				choosex = 357.5;
				choosey = 590;
				vis[44] = 1;
			}
		}
		if (msg.x > 430 && msg.x < 525 && msg.y > 575 && msg.y < 700)
		{
			if (!vis[45])
			{
				ischoose = true;
				choosex = 452.5;
				choosey = 590;
				vis[45] = 1;
			}
		}
		if (msg.x > 525 && msg.x < 620 && msg.y > 575 && msg.y < 700)
		{
			if (!vis[46])
			{
				ischoose = true;
				choosex = 547.5;
				choosey = 590;
				vis[46] = 1;
			}
		}
		if (msg.x > 620 && msg.x < 715 && msg.y > 575 && msg.y < 700)
		{
			if (!vis[47])
			{
				ischoose = true;
				choosex = 642.5;
				choosey = 590;
				vis[47] = 1;
			}
		}
		if (msg.x > 715 && msg.x < 810 && msg.y > 575 && msg.y < 700)
		{
			if (!vis[48])
			{
				ischoose = true;
				choosex = 737.5;
				choosey = 590;
				vis[48] = 1;
			}
		}
		if (msg.x > 810 && msg.x < 905 && msg.y > 575 && msg.y < 700)
		{
			if (!vis[49])
			{
				ischoose = true;
				choosex = 832.5;
				choosey = 590;
				vis[49] = 1;
			}
		}
		if (msg.x > 905 && msg.x < 1000 && msg.y > 575 && msg.y < 700)
		{
			if (!vis[50])
			{
				ischoose = true;
				choosex = 927.5;
				choosey = 590;
				vis[50] = 1;
			}
		}
	}
}

void initmap()  //初始化关卡地图
{
	TCHAR goldstr[10];
	settextstyle(30, 15, _T("Kristen ITC"));
	_stprintf_s(goldstr, _T("%d"), gold);
	outtextxy(95, 40, goldstr);  //输出当前金币剩余量
	for (int i = 50; i <= 905; i += 95)  //绘制地图分格
	{
		line(i, 75, i, 700);
	}
	for (int i = 200; i <= 575; i += 125)
	{
		line(50, i, 1000, i);
	}
}

void generatecoin()  //每隔一段时间自然产生金币
{
	gencoicnt++;
	if (gencoicnt == 750)
	{
		coin temc(100 + rand() % 800, 100, 1, Gold, GoldY);
		coins.push_back(temc);
		gencoicnt = 0;
	}
}

void hitcoin(MOUSEMSG msg)  //收集金币
{
	for (auto it = coins.begin(); it != coins.end();)
	{
		if (msg.x >= (*it).x - 10 && msg.x <= (*it).x + 40 && msg.y >= (*it).y - 10 && msg.y <= (*it).y + 40 && msg.uMsg == WM_LBUTTONDOWN)
		{
			it = coins.erase(it);
			gold += 50;
		}
		else
		{
			it++;
		}
	}
}

void hitreturn(MOUSEMSG msg)  //点击返回按钮
{
	if (IsMouseInButton(retu, msg))
	{
		if (msg.uMsg == WM_LBUTTONDOWN)
		{
			flag = 2;
			retu.isactive = false;
			peoples.clear();
			enemies.clear();
			bullets.clear();
		}
	}
}

void hitskip(MOUSEMSG msg)  //动画中点击跳过按钮
{
	if (msg.x >= 900 && msg.x <= 1000 && msg.y >= 650 && msg.y <= 700 && msg.uMsg == WM_LBUTTONDOWN)
	{
		cartflag = 1;
	}
}

void forpeople()  //遍历每个友方单位
{
	for (auto it = peoples.begin(); it != peoples.end();)
	{
		if ((*it).type == 2)
		{
			putimage((*it).x, (*it).y, &(*it).img);  //出货箱比较特殊，没做掩码图，因为原图就没有背景
		}
		else
		{
			putimage((*it).x, (*it).y, &(*it).imgY, SRCAND);
			putimage((*it).x, (*it).y, &(*it).img, SRCPAINT);
		}
		(*it).cnt++;  //增加友方对象行为计数器
		if ((*it).type == 1)
		{
			if ((*it).cnt == 150)  //卡米莉亚 计数到150出子弹
			{
				int tem = add();
				if (tem != -1)
				{
					bulletsre[tem].x = (*it).x;
					bulletsre[tem].y = (*it).y;
					bulletsre[tem].type = 1;
					bulletsre[tem].speed = 10;
					bulletsre[tem].attack = 10;
					bulletsre[tem].img = CamelliaBullet;
					bulletsre[tem].imgY = CamelliaBulletY;
				}
				else
				{
					bullet temb((*it).x, (*it).y, 1, 10, 10, CamelliaBullet, CamelliaBulletY);
					bullets.push_back(temb);
				}
				(*it).cnt = 0;
			}
			it++;
		}
		else if ((*it).type == 2)
		{
			if ((*it).cnt == 1500)  //出货箱 计数到1500产生金币
			{
				coin tem((*it).x + 10 + rand() % 40, (*it).y + 70, 2, Gold, GoldY);
				coins.push_back(tem);
				(*it).cnt = 0;
			}
			it++;
		}
		else if ((*it).type == 3)
		{
			if ((*it).cnt == 150)  //刘易斯 计数到150出子弹
			{
				int tem = add();
				if (tem != -1)
				{
					bulletsre[tem].x = (*it).x;
					bulletsre[tem].y = (*it).y;
					bulletsre[tem].type = 3;
					bulletsre[tem].speed = 10;
					bulletsre[tem].attack = 5;
					bulletsre[tem].img = LewisBullet;
					bulletsre[tem].imgY = LewisBulletY;
				}
				else
				{
					bullet temb((*it).x, (*it).y, 3, 10, 5, LewisBullet, LewisBulletY);
					bullets.push_back(temb);
				}
				(*it).cnt = 0;
			}
			it++;
		}
		else if ((*it).type == 4)
		{
			if ((*it).cnt == 80)  //炸弹 计数到80爆炸然后自身也删除掉
			{
				for (auto ite = enemies.begin(); ite != enemies.end();)
				{
					if ((*ite).x >= (*it).x - 100 && (*ite).x <= (*it).x + 100 && (*ite).y >= (*it).y - 150 && (*ite).y <= (*it).y + 150)
					{
						(*ite).health -= 50;
					}
					ite++;
				}
				it = peoples.erase(it);
			}
			else
			{
				it++;
			}
		}
		else if ((*it).type == 5)
		{
			if ((*it).cnt == 150)  //塞巴斯蒂安 计数到150出子弹
			{
				int tem = add();
				if (tem != -1)
				{
					bulletsre[tem].x = (*it).x;
					bulletsre[tem].y = (*it).y + 40;
					bulletsre[tem].type = 5;
					bulletsre[tem].speed = 30;
					bulletsre[tem].attack = 7;
					bulletsre[tem].img = SebastianBullet;
					bulletsre[tem].imgY = SebastianBulletY;
				}
				else
				{
					bullet temb((*it).x, (*it).y, 5, 10, 8, SebastianBullet, SebastianBulletY);
					bullets.push_back(temb);
				}
				(*it).cnt = 0;
				for (auto it2 = enemies.begin(); it2 != enemies.end();)  //这个比较特殊，因为是一次攻击一整行（对象右面的全部敌人），所以直接在人物这里写的攻击代码
				{
					if ((*it2).y == (*it).y && (*it2).x >= (*it).x)
					{
						(*it2).health -= 7;
						it2++;
					}
					else
					{
						it2++;
					}
				}
			}
			it++;
		}
		else if ((*it).type == 6)  //路障 没有操作，就是生命值高，用来阻挡敌人的
		{
			it++;
		}
	}
}

void forbullet()
{
	for (int i = 0; i <= 999; i++)  //bulletsre预留子弹数组
	{
		if (bulletsre[i].type == 0)  //这个预留位置没子弹
		{
			continue;
		}
		if (bulletsre[i].type == 1)  //卡米莉亚的子弹
		{
			bool hit = false;
			bulletsre[i].x += bulletsre[i].speed;
			for (auto it2 = enemies.begin(); it2 != enemies.end();)
			{
				if (bulletsre[i].y == (*it2).y && bulletsre[i].x >= (*it2).x && bulletsre[i].x <= (*it2).x + 20)  //遍历敌人对象，看是否打到
				{
					(*it2).health -= bulletsre[i].attack;
					hit = true;
					break;
				}
				it2++;
			}
			putimage(bulletsre[i].x, bulletsre[i].y, &bulletsre[i].imgY, SRCAND);
			putimage(bulletsre[i].x, bulletsre[i].y, &bulletsre[i].img, SRCPAINT);
			if (hit || bulletsre[i].x >= 1000)
			{
				bulletsre[i].type = 0;  //打到敌人了或者出屏幕了，子弹对象就删除
			}
		}
		if (bulletsre[i].type == 3)  //刘易斯的子弹 有上减速buff的效果
		{
			bool hit = false;
			bulletsre[i].x += bulletsre[i].speed;
			for (auto it2 = enemies.begin(); it2 != enemies.end();)
			{
				if (bulletsre[i].y == (*it2).y && bulletsre[i].x >= (*it2).x && bulletsre[i].x <= (*it2).x + 20)
				{
					(*it2).slowcnt = 300;  //减速buff
					(*it2).health -= bulletsre[i].attack;
					hit = true;
					break;
				}
				it2++;
			}
			putimage(bulletsre[i].x, bulletsre[i].y, &bulletsre[i].imgY, SRCAND);
			putimage(bulletsre[i].x, bulletsre[i].y, &bulletsre[i].img, SRCPAINT);
			if (hit || bulletsre[i].x >= 1000)
			{
				bulletsre[i].type = 0;
			}
		}
		if (bulletsre[i].type == 5)  //塞巴斯蒂安的子弹，攻击代码在人物那里，这个子弹就只有外观显示
		{
			bulletsre[i].x += bulletsre[i].speed;
			putimage(bulletsre[i].x, bulletsre[i].y, &bulletsre[i].imgY, SRCAND);
			putimage(bulletsre[i].x, bulletsre[i].y, &bulletsre[i].img, SRCPAINT);
			if (bulletsre[i].x >= 1000)  
			{
				bulletsre[i].type = 0;
			}
		}
		if (bulletsre[i].type == 7)  //骷髅的子弹，也比较特殊，是唯一一个敌方单位产生打友方单位的，所有内容都反过来
		{
			bool hit = false;
			bulletsre[i].x -= bulletsre[i].speed;
			for (auto it2 = peoples.begin(); it2 != peoples.end();)
			{
				if (bulletsre[i].y == (*it2).y && bulletsre[i].x <= (*it2).x && bulletsre[i].x >= (*it2).x - 20)
				{
					(*it2).health -= bulletsre[i].attack;
					hit = true;
					if ((*it2).health <= 0)
					{
						vis[static_cast<int>((*it2).y / 125) * 10 + static_cast<int>((*it2).x / 95) + 1] = 0;
						it2 = peoples.erase(it2);
					}
					break;
				}
				it2++;
			}
			putimage(bulletsre[i].x, bulletsre[i].y, &bulletsre[i].imgY, SRCAND);
			putimage(bulletsre[i].x, bulletsre[i].y, &bulletsre[i].img, SRCPAINT);
			if (hit || bulletsre[i].x < 50)
			{
				bulletsre[i].type = 0;
			}
		}
	}
	for (auto it1 = bullets.begin(); it1 != bullets.end();)  //bulletsvector，和上面类似
	{
		if ((*it1).type == 1)
		{
			bool hit = false;
			(*it1).x += (*it1).speed;
			for (auto it2 = enemies.begin(); it2 != enemies.end();)
			{
				if ((*it1).y == (*it2).y && (*it1).x >= (*it2).x && (*it1).x <= (*it2).x + 20)
				{
					(*it2).health -= (*it1).attack;
					hit = true;
					break;
				}
				it2++;
			}
			putimage((*it1).x, (*it1).y, &((*it1).imgY), SRCAND);
			putimage((*it1).x, (*it1).y, &((*it1).img), SRCPAINT);
			if (hit || (*it1).x >= 1000)
			{
				it1 = bullets.erase(it1);
			}
			else
			{
				it1++;
			}
		}
		if ((*it1).type == 3)
		{
			bool hit = false;
			(*it1).x += (*it1).speed;
			for (auto it2 = enemies.begin(); it2 != enemies.end();)
			{
				if ((*it1).y == (*it2).y && (*it1).x >= (*it2).x && (*it1).x <= (*it2).x + 20)
				{
					(*it2).slowcnt = 300;
					(*it2).health -= (*it1).attack;
					hit = true;
					break;
				}
				it2++;
			}
			putimage((*it1).x, (*it1).y, &((*it1).imgY), SRCAND);
			putimage((*it1).x, (*it1).y, &((*it1).img), SRCPAINT);
			if (hit || (*it1).x >= 1000)
			{
				it1 = bullets.erase(it1);
			}
			else
			{
				it1++;
			}
		}
		if ((*it1).type == 5)
		{
			(*it1).x += (*it1).speed;
			putimage((*it1).x, (*it1).y, &((*it1).imgY), SRCAND);
			putimage((*it1).x, (*it1).y, &((*it1).img), SRCPAINT);
			if ((*it1).x >= 1000)
			{
				it1 = bullets.erase(it1);
			}
			else
			{
				it1++;
			}
		}
		if ((*it1).type == 7)
		{
			bool hit = false;
			(*it1).x -= (*it1).speed;
			for (auto it2 = peoples.begin(); it2 != peoples.end();)
			{
				if ((*it1).y == (*it2).y && (*it1).x <= (*it2).x && (*it1).x >= (*it2).x - 20)
				{
					(*it2).health -= (*it1).attack;
					hit = true;
					if ((*it2).health <= 0)
					{
						vis[static_cast<int>((*it2).y / 125) * 10 + static_cast<int>((*it2).x / 95) + 1] = 0;
						it2 = peoples.erase(it2);
					}
					break;
				}
				it2++;
			}
			putimage((*it1).x, (*it1).y, &((*it1).imgY), SRCAND);
			putimage((*it1).x, (*it1).y, &((*it1).img), SRCPAINT);
			if (hit || (*it1).x < 50)
			{
				it1 = bullets.erase(it1);
			}
			else
			{
				it1++;
			}
		}
	}
}

void forenemy()  //遍历敌人
{
	for (auto it2 = enemies.begin(); it2 != enemies.end();)
	{
		if ((*it2).health <= 0)  //判断是否死亡
		{
			if ((*it2).type == 4)  //如果是大史莱姆，就爆出几个小史莱姆
			{
				enemy tem1((*it2).x - 20, (*it2).y, 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
				enemyaddtem.push_back(tem1);
				enemy tem2((*it2).x + 20, (*it2).y, 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
				enemyaddtem.push_back(tem2);
				if ((*it2).y != 90)
				{
					enemy tem3((*it2).x, (*it2).y - 125, 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
					enemyaddtem.push_back(tem3);
				}
				if ((*it2).y != 590)
				{
					enemy tem4((*it2).x, (*it2).y + 125, 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
					enemyaddtem.push_back(tem4);
				}
			}
			it2 = enemies.erase(it2);
			kill++;  //增加击杀计数器
			continue;
		}
		double realspeed;
		double realattack;
		if ((*it2).slowcnt > 0)
		{
			(*it2).slowcnt--;
			realspeed = (*it2).speed / 2;  //如果减速计数器不为0，移速和攻击都减为一半
			realattack = (*it2).attack / 2;
			putimage((*it2).x, (*it2).y, &(*it2).imgslowY, SRCAND);
			putimage((*it2).x, (*it2).y, &(*it2).imgslow, SRCPAINT);
		}
		else
		{
			realspeed = (*it2).speed;
			realattack = (*it2).attack;
			putimage((*it2).x, (*it2).y, &(*it2).imgY, SRCAND);
			putimage((*it2).x, (*it2).y, &(*it2).img, SRCPAINT);
		}
		int stopflag = 0;
		for (auto it = peoples.begin(); it != peoples.end();)
		{
			if ((*it).y == (*it2).y && (*it2).x <= (*it).x + 20 && (*it2).x >= (*it).x - 20)
			{
				stopflag = 1;  //被友方对象阻碍
				(*it).health -= realattack;  //攻击友方对象
			}
			if ((*it).health <= 0)  //打死了友方对象
			{
				vis[static_cast<int>((*it).y / 125) * 10 + static_cast<int>((*it).x / 95) + 1] = 0;  //对应那个友方对象位置可以放新的了·
				it = peoples.erase(it);
			}
			else
			{
				it++;
			}
		}
		if (!stopflag)
		{
			(*it2).x -= realspeed;
		}
		if ((*it2).x < 50)  //敌人有走到地图左底线的了，判定失败
		{
			Sleep(1000);
			putimage(0, 0, &Die);
			FlushBatchDraw();
			peoples.clear();
			enemies.clear();
			bullets.clear();
			retu.isactive = false;
			flag = 1;
			Sleep(3000);
			break;
		}
		if ((*it2).type == 5)  //骷髅的随机事件
		{
			int tem = rand() % 800;  //每次循环都有1/800的概率发射子弹
			if (tem == 500)
			{
				int temp = add();
				if (temp != -1)
				{
					bulletsre[temp].x = (*it2).x;
					bulletsre[temp].y = (*it2).y;
					bulletsre[temp].type = 7;
					bulletsre[temp].speed = 10;
					bulletsre[temp].attack = 50;
					bulletsre[temp].img = SkeletonBullet;
				}
				else
				{
					bullet temb((*it2).x, (*it2).y, 7, 10, 50, SkeletonBullet, SkeletonBulletY);
					bullets.push_back(temb);
				}
			}
		}
		if ((*it2).type == 6)  //幽灵的随机事件
		{
			int tem = rand() % 800;  //每次循环都有1/800的概率随机平移
			if (tem == 500)
			{
				int tem1 = rand() % 5;
				if (tem1 == 0)
				{
					(*it2).y = 90;
				}
				else if (tem1 == 1)
				{
					(*it2).y = 215;
				}
				else if (tem1 == 2)
				{
					(*it2).y = 340;
				}
				else if (tem1 == 3)
				{
					(*it2).y = 465;
				}
				else if (tem1 == 4)
				{
					(*it2).y = 590;
				}
			}
		}
		it2++;
	}
	for (auto& et : enemyaddtem)  //把临时vector的加到敌人vector
	{
		enemies.push_back(et);
	}
	enemyaddtem.clear();
}

void forcoin()  //遍历金币
{
	for (auto it = coins.begin(); it != coins.end();)
	{
		putimage((*it).x, (*it).y, &(*it).imgY, SRCAND);
		putimage((*it).x, (*it).y, &(*it).img, SRCPAINT);
		if ((*it).type == 1)
		{
			(*it).y += 2;
			if ((*it).y >= 700)
			{
				it = coins.erase(it);
			}
			else
			{
				it++;
			}
		}
		else
		{
			it++;
		}
	}
}

void cartoon()  //放映动画的代码
{
	putimage(0, 0, &Cartbg);
	putimage(900, 650, &Skip);
	if (MouseHit())
	{
		MOUSEMSG msg = GetMouseMsg();
		hitskip(msg);
	}
	if (cartcnt <= 450 && (cartcnt / 20 % 2) == 0)
	{
		putimage(100 + cartcnt, 340, &Clint4Y, SRCAND);
		putimage(100 + cartcnt, 340, &Clint4, SRCPAINT);
		cartcnt++;
	}
	if (cartcnt <= 450 && (cartcnt / 20 % 2) == 1)
	{
		putimage(100 + cartcnt, 340, &Clint2Y, SRCAND);
		putimage(100 + cartcnt, 340, &Clint2, SRCPAINT);
		cartcnt++;
	}
	if (cartcnt >= 450 && cartcnt <= 600 && (cartcnt - 450) / 20 % 3 == 0)
	{
		putimage(555, 343, &Clint1Y, SRCAND);
		putimage(555, 343, &Clint1, SRCPAINT);
		putimage(860, 300 + cartcnt - 450, &Slime2Y, SRCAND);
		putimage(860, 300 + cartcnt - 450, &Slime2, SRCPAINT);
		cartcnt++;
	}
	if (cartcnt >= 450 && cartcnt <= 600 && (cartcnt - 450) / 20 % 3 == 1)
	{
		putimage(555, 343, &Clint1Y, SRCAND);
		putimage(555, 343, &Clint1, SRCPAINT);
		putimage(860, 300 + cartcnt - 450, &Slime3Y, SRCAND);
		putimage(860, 300 + cartcnt - 450, &Slime3, SRCPAINT);
		cartcnt++;
	}
	if (cartcnt >= 450 && cartcnt <= 600 && (cartcnt - 450) / 20 % 3 == 2)
	{
		putimage(555, 343, &Clint1Y, SRCAND);
		putimage(555, 343, &Clint1, SRCPAINT);
		putimage(860, 315 + cartcnt - 450, &Slime1Y, SRCAND);
		putimage(860, 315 + cartcnt - 450, &Slime1, SRCPAINT);
		cartcnt++;
	}
	if (cartcnt >= 550 && cartcnt <= 600 && (cartcnt - 500) / 20 % 2 == 0)
	{
		putimage(860, 315 + cartcnt - 550, &Metalhead2Y, SRCAND);
		putimage(860, 315 + cartcnt - 550, &Metalhead2, SRCPAINT);
	}
	if (cartcnt >= 550 && cartcnt <= 600 && (cartcnt - 500) / 20 % 2 == 1)
	{
		putimage(860, 315 + cartcnt - 550, &Metalhead3Y, SRCAND);
		putimage(860, 315 + cartcnt - 550, &Metalhead3, SRCPAINT);
	}
	if (cartcnt >= 600 && cartcnt <= 650)
	{
		putimage(555, 343, &Clint1Y, SRCAND);
		putimage(555, 343, &Clint1, SRCPAINT);
		putimage(860, 450, &Slime2Y, SRCAND);
		putimage(860, 450, &Slime2, SRCPAINT);
	}
	if (cartcnt >= 600 && cartcnt <= 650)
	{
		putimage(860, 355, &Metalhead1Y, SRCAND);
		putimage(860, 355, &Metalhead1, SRCPAINT);
		cartcnt++;
	}
	if (cartcnt > 650 && cartcnt < 1100)
	{
		putimage(860, 450, &Slime2Y, SRCAND);
		putimage(860, 450, &Slime2, SRCPAINT);
		putimage(860, 355, &Metalhead1Y, SRCAND);
		putimage(860, 355, &Metalhead1, SRCPAINT);
	}
	if (cartcnt > 650 && cartcnt <= 655)
	{
		putimage(555, 343 - (cartcnt - 650), &Clint3Y, SRCAND);
		putimage(555, 343 - (cartcnt - 650), &Clint3, SRCPAINT);
		cartcnt++;
	}
	if (cartcnt > 655 && cartcnt <= 745)
	{
		putimage(555, 338, &Clint3Y, SRCAND);
		putimage(555, 338, &Clint3, SRCPAINT);
		cartcnt++;
	}
	if (cartcnt > 745 && cartcnt <= 750)
	{
		putimage(555, 338 + (cartcnt - 745), &Clint4Y, SRCAND);
		putimage(555, 338 + (cartcnt - 745), &Clint4, SRCPAINT);
		cartcnt++;
	}
	if (cartcnt > 750 && cartcnt <= 1000 && (cartcnt / 10 % 2) == 0)
	{
		putimage(550 - 2 * (cartcnt - 750), 340, &Clint5Y, SRCAND);
		putimage(550 - 2 * (cartcnt - 750), 340, &Clint5, SRCPAINT);
		cartcnt++;
	}
	if (cartcnt > 750 && cartcnt <= 1000 && (cartcnt / 10 % 2) == 1)
	{
		putimage(550 - 2 * (cartcnt - 750), 340, &Clint6Y, SRCAND);
		putimage(550 - 2 * (cartcnt - 750), 340, &Clint6, SRCPAINT);
		cartcnt++;
	}
	if (cartcnt > 1000 && cartcnt < 1100)
	{
		cartcnt++;
	}
	if (cartcnt == 1100)
	{
		cartflag = 1;
		cartcnt = 0;
	}
	FlushBatchDraw();
	Sleep(10);
}

int getrow(int x)  //生成敌人时用来随机所在行
{
	x %= 5;
	if (x == 0)
	{
		return 90;
	}
	else if (x == 1)
	{
		return 215;
	}
	else if (x == 2)
	{
		return 340;
	}
	else if (x == 3)
	{
		return 465;
	}
	else
	{
		return 590;
	}
}

int main()
{
	srand(time(0));
	initgraph(1000, 700);
	loadimage(&imgPVZ, _T("PVZ.png"), 1000, 750);
	loadimage(&waiting, _T("Waiting.jpg"), 1000, 750);
	loadimage(&Camellia, _T("Camellia.png"), 50, 100);
	loadimage(&CamelliaY, _T("CamelliaY.png"), 50, 100);
	loadimage(&CamelliaLOGO, _T("Camellia.png"), 150, 300);
	loadimage(&CamelliaLOGOY, _T("CamelliaY.png"), 150, 300);
	loadimage(&CamelliaBullet, _T("CamelliaBullet.png"), 25, 25);
	loadimage(&CamelliaBulletY, _T("CamelliaBulletY.png"), 25, 25);
	loadimage(&Salebox, _T("Salebox.png"), 50, 50);
	loadimage(&SaleboxLOGO, _T("Salebox.png"), 150, 150);
	loadimage(&Lewis, _T("Lewis.png"), 50, 100);
	loadimage(&LewisY, _T("LewisY.png"), 50, 100);
	loadimage(&LewisLOGO, _T("Lewis.png"), 150, 300);
	loadimage(&LewisLOGOY, _T("LewisY.png"), 150, 300);
	loadimage(&LewisBullet, _T("LewisBullet.png"), 25, 25);
	loadimage(&LewisBulletY, _T("LewisBulletY.png"), 25, 25);
	loadimage(&Boom, _T("Boom.png"), 50, 50);
	loadimage(&BoomLOGO, _T("Boom.png"), 150, 50);
	loadimage(&Block, _T("Block.png"), 50, 100);
	loadimage(&BlockLOGO, _T("Block.png"), 150, 300);
	loadimage(&Sebastian, _T("Sebastian.png"), 50, 100);
	loadimage(&SebastianLOGO, _T("Sebastian.png"), 150, 300);
	loadimage(&SebastianBullet, _T("SebastianBullet.png"), 25, 25);
	loadimage(&BoomY, _T("BoomY.png"), 50, 50);
	loadimage(&BlockY, _T("BlockY.png"), 50, 100);
	loadimage(&SebastianY, _T("SebastianY.png"), 50, 100);
	loadimage(&BoomLOGOY, _T("BoomY.png"), 150, 150);
	loadimage(&BlockLOGOY, _T("BlockY.png"), 150, 300);
	loadimage(&SebastianLOGOY, _T("SebastianY.png"), 150,300);
	loadimage(&SebastianBulletY, _T("SebastianBulletY.png"), 25, 25);
	loadimage(&Zombie, _T("Zombie.png"), 50, 100);
	loadimage(&Gold, _T("Gold.png"), 30, 30);
	loadimage(&GoldY, _T("GoldY.png"), 30, 30);
	loadimage(&Path, _T("Path.png"), 950, 125);
	loadimage(&House, _T("House.png"), 50, 750);
	loadimage(&Die, _T("Die.png"), 1000, 700);
	loadimage(&Victory, _T("Victory.png"), 1000, 700);
	loadimage(&Cartbg, _T("Cartbg.png"), 1000, 700);
	loadimage(&Clint1, _T("Clint1.png"), 50, 100);
	loadimage(&Clint2, _T("Clint2.png"), 50, 100);
	loadimage(&Clint3, _T("Clint3.png"), 50, 100);
	loadimage(&Clint4, _T("Clint4.png"), 55, 100);
	loadimage(&Clint5, _T("Clint5.png"), 50, 100);
	loadimage(&Clint6, _T("Clint6.png"), 50, 100);
	loadimage(&Slime1, _T("Slime1.png"), 60, 40);
	loadimage(&Slime2, _T("Slime2.png"), 50, 50);
	loadimage(&Slime3, _T("Slime3.png"), 45, 60);
	loadimage(&SlimeLOGO, _T("Slime3.png"), 150, 150);
	loadimage(&Slimeslow, _T("Slimeslow.jpg"), 45, 60);
	loadimage(&Metalhead1, _T("Metalhead1.png"), 50, 50);
	loadimage(&Metalhead2, _T("Metalhead2.png"), 50, 50);
	loadimage(&Metalhead3, _T("Metalhead3.png"), 50, 50);
	loadimage(&RedSlime, _T("RedSlime.png"), 50, 50);
	loadimage(&RedSlimeLOGO, _T("RedSlime.png"), 150, 150);
	loadimage(&RedSlimeSlow, _T("RedSlimeSlow.jpg"), 50, 50);
	loadimage(&BlueSlime, _T("BlueSlime.png"), 50, 50);
	loadimage(&BlueSlimeLOGO, _T("BlueSlime.png"), 150, 150);
	loadimage(&BlueSlimeSlow, _T("BlueSlimeSlow.jpg"), 50, 50);
	loadimage(&BigSlime, _T("BigSlime.png"), 90, 90);
	loadimage(&BigSlimeLOGO, _T("BigSlime.png"), 150, 150);
	loadimage(&BigSlimeSlow, _T("BigSlimeSlow.jpg"), 90, 90);
	loadimage(&Skeleton, _T("Skeleton.png"), 50, 100);
	loadimage(&SkeletonLOGO, _T("Skeleton.png"), 150, 300);
	loadimage(&SkeletonSlow, _T("SkeletonSlow.jpg"), 50, 100);
	loadimage(&SkeletonBullet, _T("SkeletonBullet.png"), 25, 25);
	loadimage(&Ghost, _T("Ghost.png"), 50, 75);
	loadimage(&GhostLOGO, _T("Ghost.png"), 150, 300);
	loadimage(&GhostSlow, _T("GhostSlow.jpg"), 50, 75);
	loadimage(&Clint1Y, _T("Clint1Y.png"), 50, 100);
	loadimage(&Clint2Y, _T("Clint2Y.png"), 50, 100);
	loadimage(&Clint3Y, _T("Clint3Y.png"), 50, 100);
	loadimage(&Clint4Y, _T("Clint4Y.png"), 55, 100);
	loadimage(&Clint5Y, _T("Clint5Y.png"), 50, 100);
	loadimage(&Clint6Y, _T("Clint6Y.png"), 50, 100);
	loadimage(&Slime1Y, _T("Slime1Y.png"), 60, 40);
	loadimage(&Slime2Y, _T("Slime2Y.png"), 50, 50);
	loadimage(&Slime3Y, _T("Slime3Y.png"), 45, 60);
	loadimage(&SlimeLOGOY, _T("Slime3Y.png"), 150, 150);
	loadimage(&SlimeslowY, _T("SlimeslowY.png"), 45, 60);
	loadimage(&Metalhead1Y, _T("Metalhead1Y.png"), 50, 50);
	loadimage(&Metalhead2Y, _T("Metalhead2Y.png"), 50, 50);
	loadimage(&Metalhead3Y, _T("Metalhead3Y.png"), 50, 50);
	loadimage(&RedSlimeY, _T("RedSlimeY.png"), 50, 50);
	loadimage(&RedSlimeLOGOY, _T("RedSlimeY.png"), 150, 150);
	loadimage(&RedSlimeSlowY, _T("RedSlimeSlowY.png"), 50, 50);
	loadimage(&BlueSlimeY, _T("BlueSlimeY.png"), 50, 50);
	loadimage(&BlueSlimeLOGOY, _T("BlueSlimeY.png"), 150, 150);
	loadimage(&BlueSlimeSlowY, _T("BlueSlimeSlowY.png"), 50, 50);
	loadimage(&BigSlimeY, _T("BigSlimeY.png"), 90, 90);
	loadimage(&BigSlimeLOGOY, _T("BigSlimeY.png"), 150, 150);
	loadimage(&BigSlimeSlowY, _T("BigSlimeSlowY.png"), 90, 90);
	loadimage(&SkeletonY, _T("SkeletonY.png"), 50, 100);
	loadimage(&SkeletonLOGOY, _T("SkeletonY.png"), 150, 300);
	loadimage(&SkeletonSlowY, _T("SkeletonSlowY.png"), 50, 100);
	loadimage(&SkeletonBulletY, _T("SkeletonBulletY.png"), 25, 25);
	loadimage(&GhostY, _T("GhostY.png"), 50, 75);
	loadimage(&GhostLOGOY, _T("GhostY.png"), 150, 300);
	loadimage(&GhostSlowY, _T("GhostSlowY.png"), 50, 75);
	loadimage(&Skip, _T("Skip.png"), 100, 50);
	loadimage(&CammyPrice, _T("CammyPrice.jpg"), 100, 75);
	loadimage(&CammyPriceNo, _T("CammyPriceNo.jpg"), 100, 75);
	loadimage(&SaleboxPrice, _T("SaleboxPrice.jpg"), 100, 75);
	loadimage(&SaleboxPriceNo, _T("SaleboxPriceNo.jpg"), 100, 75);
	loadimage(&LewisPrice, _T("LewisPrice.jpg"), 100, 75);
	loadimage(&LewisPriceNo, _T("LewisPriceNo.jpg"), 100, 75);
	loadimage(&BoomPrice, _T("BoomPrice.jpg"), 100, 75);
	loadimage(&BoomPriceNo, _T("BoomPriceNo.jpg"), 100, 75);
	loadimage(&BlockPrice, _T("BlockPrice.jpg"), 100, 75);
	loadimage(&BlockPriceNo, _T("BlockPriceNo.jpg"), 100, 75);
	loadimage(&SebastianPrice, _T("SebastianPrice.jpg"), 100, 75);
	loadimage(&SebastianPriceNo, _T("SebastianPriceNo.jpg"), 100, 75);
	loadimage(&Wave, _T("Wave.jpg"), 200, 100);
	loadimage(&LastWave, _T("LastWave.jpg"), 200, 100);
	loadimage(&Background, _T("Background.png"), 1000, 700);
	loadimage(&Pause, _T("Pause.png"), 400, 200);
	loadimage(&PauseButton, _T("PauseButton.jpg"), 75, 75);
	loadimage(&Continue, _T("Continue.jpg"), 75, 75);

	loadimage(&exi.normal, _T("SDVexit.png"), 125, 125);   
	loadimage(&exi.hover, _T("SDVexit.png"), 140, 140);   
	loadimage(&start.normal, _T("SDVstart.png"), 125, 125);
	loadimage(&start.hover, _T("SDVstart.png"), 140, 140);
	loadimage(&retu.normal, _T("Return.png"), 100, 50);
	loadimage(&retu.hover, _T("Return.png"), 125, 75);
	loadimage(&level1.normal, _T("SDV1.png"), 150, 150);
	loadimage(&level1.hover, _T("SDV1.png"), 175, 175);
	loadimage(&level20.normal, _T("SDV20.png"), 150, 150);
	loadimage(&level20.hover, _T("SDV20.png"), 175, 175);
	loadimage(&level21.normal, _T("SDV21.png"), 150, 150);
	loadimage(&level21.hover, _T("SDV21.png"), 175, 175);
	loadimage(&level30n, _T("SDV30.png"), 150, 150);
	loadimage(&level30h, _T("SDV30.png"), 175, 175);
	loadimage(&level31.normal, _T("SDV31.png"), 150, 150);
	loadimage(&level31.hover, _T("SDV31.png"), 175, 175);
	loadimage(&Help.normal, _T("Help.png"), 150, 150);
	loadimage(&Help.hover, _T("Help.png"), 175, 175);
	start.init();
	exi.init();
	retu.init();
	level1.init();
	level20.init();
	level21.init();
	level31.init();
	Help.init();
	bool isRunning = true;
	flag = 1;
	while (isRunning) {
		BeginBatchDraw();
		cleardevice();
		if (flag == 1)  //主页面
		{
			start.isactive = true;
			exi.isactive = true;
			putimage(0, 0, &imgPVZ);
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(800, 645, _T("制作："));
			outtextxy(670, 675, _T("素材来源：星露谷物语、植物大战僵尸"));
			settextstyle(30, 10, _T("Kristen ITC"));
			outtextxy(850, 645, _T("CamelliaGreen"));
			if (winflag)
			{
				settextstyle(50, 15, _T("华文行楷"));
				outtextxy(180, 200, _T("你成功抵御了矿洞怪物的入侵！"));
				outtextxy(330, 260, _T("感谢你的游玩！"));
			}
			MOUSEMSG msg = GetMouseMsg();
			if (IsMouseInButton(exi, msg))
			{
				if (msg.uMsg == WM_LBUTTONDOWN)
				{
					FlushBatchDraw();
					Sleep(100); 
					closegraph(); 
					return 0;
				}
				else
				{
					putimage(exi.x, exi.y, &exi.hover);
				}
			}
			else
			{
				putimage(exi.x, exi.y, &exi.normal);
			}
			if (IsMouseInButton(start, msg))
			{
				if (msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 2;
					start.isactive = false;
					exi.isactive = false;
				}
				else
				{
					putimage(start.x, start.y, &start.hover);
				}
			}
			else
			{
				putimage(start.x, start.y, &start.normal);
			}
		}
		if (flag == 2)  //选关页面
		{
			putimage(0, 0, &imgPVZ);
			putimage(retu.x, retu.y, &retu.normal);
			retu.isactive = true;
			level1.isactive = true;
			Help.isactive = true;
			if (level2)
			{
				level20.isactive = false;
				level21.isactive = true;
			}
			else
			{
				level20.isactive = true;
				level21.isactive = false;
			}
			if (level3)
			{
				level31.isactive = true;
			}
			else
			{
				level31.isactive = false;
			}
			MOUSEMSG msg = GetMouseMsg();
			if (IsMouseInButton(retu, msg))
			{
				if (msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 1;
					retu.isactive = false;
					level1.isactive = false;
					level20.isactive = false;
					level21.isactive = false;
					level31.isactive = false;
					Help.isactive = false;
				}
			}
			if (IsMouseInButton(level1, msg))
			{
				if (msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 3;
					pauseflag = 0;
					finishcreatenemy = 0;
					retu.isactive = false;
					level1.isactive = false;
					level20.isactive = false;
					level21.isactive = false;
					level31.isactive = false;
					Help.isactive = false;
					gold = 100;
					gencoicnt = 0;
					memset(vis, 0, sizeof(vis));
					for (int i = 0; i <= 499; i++)
					{
						bulletsre[i].type = 0;
					}
					bullets.clear();
					kill = 0;
					generate = 0;
					gencoicnt = 700;
					Camelliawait = 400;
				}
				else
				{
					putimage(level1.x, level1.y, &level1.hover);
				}
			}
			else
			{
				putimage(level1.x, level1.y, &level1.normal);
			}
			if (IsMouseInButton(level20, msg))
			{
				putimage(level20.x, level20.y, &level20.hover);
			}
			else if (!level2)
			{
				putimage(level20.x, level20.y, &level20.normal);
			}
			if (IsMouseInButton(level21, msg))
			{
				if (msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 4;
					pauseflag = 0;
					finishcreatenemy = 0;
					retu.isactive = false;
					level1.isactive = false;
					level20.isactive = false;
					level21.isactive = false;
					level31.isactive = false;
					Help.isactive = false;
					gold = 150;
					memset(vis, 0, sizeof(vis));
					for (int i = 0; i <= 499; i++)
					{
						bulletsre[i].type = 0;
					}
					bullets.clear();
					kill = 0;
					generate = 0;
					gencoicnt = 700;
					Camelliawait = 400;
					Saleboxwait = 400;
					Lewiswait = 700;
					level2cnt = 0;
				}
				else
				{
					putimage(level21.x, level21.y, &level21.hover);
				}
			}
			else if (level2)
			{
				putimage(level21.x, level21.y, &level21.normal);
			}
			if (msg.x >= 750 && msg.x <= 900 && msg.y >= 300 && msg.y <= 450 && !level3)
			{
				putimage(750, 300, &level30h);
			}
			else if (!level3)
			{
				putimage(750, 300, &level30n);
			}
			if (IsMouseInButton(level31, msg))
			{
				if (msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 5;
					pauseflag = 0;
					retu.isactive = false;
					level1.isactive = false;
					level20.isactive = false;
					level21.isactive = false;
					level31.isactive = false;
					Help.isactive = false;
					gold = 150;
					memset(vis, 0, sizeof(vis));
					for (int i = 0; i <= 499; i++)
					{
						bulletsre[i].type = 0;
					}
					bullets.clear();
					kill = 0;
					generate = 0;
					gencoicnt = 700;
					Camelliawait = 400;
					Saleboxwait = 400;
					Lewiswait = 700;
					Boomwait = 2000;
					Sebastianwait = 700;
					Blockwait = 1000;
					level3cnt = 0;
				}
				else
				{
					putimage(level31.x, level31.y, &level31.hover);
				}
			}
			else if (level3)
			{
				putimage(level31.x, level31.y, &level31.normal);
			}
			if (IsMouseInButton(Help, msg))
			{
				if (msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 6;
				}
				else
				{
					putimage(Help.x, Help.y, &Help.hover);
				}
			}
			else
			{
				putimage(Help.x, Help.y, &Help.normal);
			}
		}
		if (flag == 3)  //第一关
		{
			if (!cartflag)
			{
				cartoon();
				continue;
			}
			if (generate < 5)
			{
				people temp2(72.5, 215, 1, 100, Camellia, CamelliaY);
				people temp3(72.5, 340, 1, 100, Camellia, CamelliaY);
				people temp4(72.5, 465, 1, 100, Camellia, CamelliaY);
				people temp5(72.5, 590, 1, 100, Camellia, CamelliaY);
				enemy e1(900, 90, 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
				enemy e2(900, 215, 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
				enemy e3(900, 340, 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
				enemy e4(900, 465, 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
				enemy e5(900, 590, 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
				peoples.push_back(temp2);
				peoples.push_back(temp3);
				peoples.push_back(temp4);
				peoples.push_back(temp5);
				enemies.push_back(e1);
				enemies.push_back(e2);
				enemies.push_back(e3);
				enemies.push_back(e4);
				enemies.push_back(e5);
				generate = 5;
			}
			retu.isactive = true;
			putimage(60, 40, &Gold);
			putimage(50, 75, &Path);
			putimage(50, 200, &Path);
			putimage(50, 325, &Path);
			putimage(50, 450, &Path);
			putimage(50, 575, &Path);
			putimage(retu.x, retu.y, &retu.normal);
			putimage(0, 0, &House);
			if (!pauseflag)
			{
				putimage(925, 0, &PauseButton);
			}
			else
			{
				putimage(925, 0, &Continue);
				putimage(300, 250, &Pause);
			}
			if (gold >= 100 && Camelliawait == 400)
			{
				putimage(200, 0, &CammyPrice);
			}
			else
			{
				putimage(200, 0, &CammyPriceNo);
			}
			initmap();
			if (MouseHit())
			{
				MOUSEMSG msg = GetMouseMsg();
				hitcoin(msg);
				hitreturn(msg);
				if(msg.x >= 925 && msg.x <= 1000 && msg.y >= 0 && msg.y <= 75)  //点暂停
				{
					if (msg.uMsg == WM_LBUTTONDOWN && pauseflag == 0)
					{
						pauseflag = 1;
					}
					else if (msg.uMsg == WM_LBUTTONDOWN && pauseflag == 1)
					{
						pauseflag = 0;
					}
				}
				if (!pplchoose)  //鼠标检测是否点击上方添加友方对象判定区
				{
					cppl(msg);
				}
				else if(pplchoose == 1)  //鼠标检测把友方对象加到哪个格子
				{
					cgnd(msg);
					if (ischoose)
					{
						ischoose = false;
						people temp(choosex, choosey, 1, 100, Camellia, CamelliaY);
						peoples.push_back(temp);
						gold -= 100;
						Camelliawait = 0;
					}
				}
			}
			if (pauseflag)
			{
				FlushBatchDraw();
				Sleep(10);
				continue;
			}
			if (Camelliawait < 400)  //冷却不满就增加冷却计数器
			{
				Camelliawait++;
			}
			generatecoin();
			forpeople();
			if (kill >= 5)  //达到击杀数目就胜利
			{
				level2 = 1;
				Sleep(1000);
				putimage(0, 0, &Victory);
				FlushBatchDraw();
				peoples.clear();
				enemies.clear();
				bullets.clear();
				coins.clear();
				retu.isactive = false;
				flag = 1;
				Sleep(3000);
				continue;
			}
			forbullet();
			forenemy();
			forcoin();
		}
		if (flag == 4)  //第二关
		{
			retu.isactive = true;
			putimage(60, 40, &Gold);
			putimage(50, 75, &Path);
			putimage(50, 200, &Path);
			putimage(50, 325, &Path);
			putimage(50, 450, &Path);
			putimage(50, 575, &Path);
			putimage(retu.x, retu.y, &retu.normal);
			putimage(0, 0, &House);
			if (!pauseflag)
			{
				putimage(925, 0, &PauseButton);
			}
			else
			{
				putimage(925, 0, &Continue);
				putimage(300, 250, &Pause);
			}
			if (gold >= 100 && Camelliawait == 400)
			{
				putimage(200, 0, &CammyPrice);
			}
			else
			{
				putimage(200, 0, &CammyPriceNo);
			}
			if (gold >= 50 && Saleboxwait == 400)
			{
				putimage(325, 0, &SaleboxPrice);
			}
			else
			{
				putimage(325, 0, &SaleboxPriceNo);
			}
			if (gold >= 150 && Lewiswait == 700)
			{
				putimage(450, 0, &LewisPrice);
			}
			else
			{
				putimage(450, 0, &LewisPriceNo);
			}
			initmap();
			putimage(retu.x, retu.y, &retu.normal);
			if (MouseHit())
			{
				MOUSEMSG msg = GetMouseMsg();
				hitcoin(msg);
				hitreturn(msg);
				if (msg.x >= 925 && msg.x <= 1000 && msg.y >= 0 && msg.y <= 75)
				{
					if (msg.uMsg == WM_LBUTTONDOWN && pauseflag == 0)
					{
						pauseflag = 1;
					}
					else if (msg.uMsg == WM_LBUTTONDOWN && pauseflag == 1)
					{
						pauseflag = 0;
					}
				}
				if (!pplchoose)
				{
					cppl(msg);
				}
				else if (pplchoose == 1)
				{
					cgnd(msg);
					if (ischoose)
					{
						ischoose = false;
						people temp(choosex, choosey, 1, 100, Camellia, CamelliaY);
						peoples.push_back(temp);
						gold -= 100;
						Camelliawait = 0;
					}
				}
				else if (pplchoose == 2)
				{
					cgnd(msg);
					if (ischoose)
					{
						ischoose = false;
						people temp(choosex, choosey, 2, 100, Salebox, Salebox);
						peoples.push_back(temp);
						gold -= 50;
						Saleboxwait = 0;
					}
				}
				else if (pplchoose == 3)
				{
					cgnd(msg);
					if (ischoose)
					{
						ischoose = false;
						people temp(choosex, choosey, 3, 100, Lewis, LewisY);
						peoples.push_back(temp);
						gold -= 150;
						Lewiswait = 0;
					}
				}
			}
			if (pauseflag)
			{
				FlushBatchDraw();
				Sleep(10);
				continue;
			}
			generatecoin();
			if (Camelliawait < 400)
			{
				Camelliawait++;
			}
			if (Saleboxwait < 400)
			{
				Saleboxwait++;
			}
			if (Lewiswait < 700)
			{
				Lewiswait++;
			}
			level2cnt++;  //第二关计数器，下面是第二关生成怪物的代码
			if (level2cnt == 200 || level2cnt == 1200 || level2cnt == 2200 || level2cnt == 3200 || level2cnt == 4200 || level2cnt == 5200)
			{

				enemy e1(950, getrow(rand() % 5), 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
				enemies.push_back(e1);
			}
			if (level2cnt >= 5500 && level2cnt <= 6000)
			{
				putimage(400, 300, &Wave);
			}
			if (level2cnt == 6100)
			{
				for (int i = 1; i <= 3; i++)
				{
					enemy e1(950, getrow(rand() % 5 + i), 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
					enemies.push_back(e1);
				}
			}
			if (level2cnt == 6300)
			{
				enemy e1(950, getrow(rand() % 5 + 1), 2, 0.5, 3, 100, BlueSlime, BlueSlimeY, BlueSlimeSlow, BlueSlimeSlowY);
				enemies.push_back(e1);
				enemy e2(940, getrow(rand() % 5 + 1), 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
				enemies.push_back(e2);
				enemy e3(960, getrow(rand() % 5), 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
				enemies.push_back(e3);
			}
			if (level2cnt == 7000 || level2cnt == 7500 || level2cnt == 8000 || level2cnt == 8500)
			{

				enemy e1(950, getrow(rand() % 5), 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
				enemy e2(940, getrow(rand() % 5 + 1), 2, 0.5, 3, 100, BlueSlime, BlueSlimeY, BlueSlimeSlow, BlueSlimeSlowY);
				enemies.push_back(e1);
				enemies.push_back(e2);
			}
			if (level2cnt >= 8700 && level2cnt <= 9000)
			{
				putimage(400, 300, &LastWave);
			}
			if (level2cnt == 9100)
			{
				for (int i = 1; i <= 5; i++)
				{
					enemy e1(950, getrow(i), 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
					enemies.push_back(e1);
				}
			}
			if (level2cnt == 9000)
			{
				enemy e1(950, getrow(rand() % 5 + 1), 2, 0.5, 3, 100, BlueSlime, BlueSlimeY, BlueSlimeSlow, BlueSlimeSlowY);
				enemies.push_back(e1);
				enemy e2(940, getrow(rand() % 5), 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
				enemies.push_back(e2);
				enemy e3(960, getrow(rand() % 5 + 2), 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
				enemies.push_back(e3);
				enemy e4(930, getrow(rand() % 5), 3, 0.5, 3, 150, RedSlime, RedSlimeY, RedSlimeSlow, RedSlimeSlowY);
				enemies.push_back(e4);
			}
			forpeople();
			if (kill >= 29)
			{
				level3 = 1;
				Sleep(1000);
				putimage(0, 0, &Victory);
				FlushBatchDraw();
				peoples.clear();
				enemies.clear();
				bullets.clear();
				coins.clear();
				retu.isactive = false;
				flag = 1;
				Sleep(3000);
				continue;
			}
			forbullet();
			forenemy();
			forcoin();
		}
		if (flag == 5)  //第三关
		{
			retu.isactive = true;
			putimage(60, 40, &Gold);
			putimage(50, 75, &Path);
			putimage(50, 200, &Path);
			putimage(50, 325, &Path);
			putimage(50, 450, &Path);
			putimage(50, 575, &Path);
			putimage(retu.x, retu.y, &retu.normal);
			putimage(0, 0, &House);
			if (!pauseflag)
			{
				putimage(925, 0, &PauseButton);
			}
			else
			{
				putimage(925, 0, &Continue);
				putimage(300, 250, &Pause);
			}
			if (gold >= 100 && Camelliawait == 400)
			{
				putimage(200, 0, &CammyPrice);
			}
			else
			{
				putimage(200, 0, &CammyPriceNo);
			}
			if (gold >= 50 && Saleboxwait == 400)
			{
				putimage(325, 0, &SaleboxPrice);
			}
			else
			{
				putimage(325, 0, &SaleboxPriceNo);
			}
			if (gold >= 150 && Lewiswait == 700)
			{
				putimage(450, 0, &LewisPrice);
			}
			else
			{
				putimage(450, 0, &LewisPriceNo);
			}
			if (gold >= 300 && Boomwait == 2000)
			{
				putimage(575, 0, &BoomPrice);
			}
			else
			{
				putimage(575, 0, &BoomPriceNo);
			}
			if (gold >= 200 && Sebastianwait == 700)
			{
				putimage(700, 0, &SebastianPrice);
			}
			else
			{
				putimage(700, 0, &SebastianPriceNo);
			}
			if (gold >= 100 && Blockwait == 1000)
			{
				putimage(825, 0, &BlockPrice);
			}
			else
			{
				putimage(825, 0, &BlockPriceNo);
			}
			initmap();
			putimage(retu.x, retu.y, &retu.normal);
			if (MouseHit())
			{
				MOUSEMSG msg = GetMouseMsg();
				hitcoin(msg);
				hitreturn(msg);
				if (msg.x >= 925 && msg.x <= 1000 && msg.y >= 0 && msg.y <= 75)
				{
					if (msg.uMsg == WM_LBUTTONDOWN && pauseflag == 0)
					{
						pauseflag = 1;
					}
					else if (msg.uMsg == WM_LBUTTONDOWN && pauseflag == 1)
					{
						pauseflag = 0;
					}
				}
				if (!pplchoose)
				{
					cppl(msg);
				}
				else if (pplchoose == 1)  //同理，只不过能放的友方单位更多了
				{
					cgnd(msg);
					if (ischoose)
					{
						ischoose = false;
						people temp(choosex, choosey, 1, 100, Camellia, CamelliaY);
						peoples.push_back(temp);
						gold -= 100;
						Camelliawait = 0;
					}
				}
				else if (pplchoose == 2)
				{
					cgnd(msg);
					if (ischoose)
					{
						ischoose = false;
						people temp(choosex, choosey, 2, 100, Salebox, Salebox);
						peoples.push_back(temp);
						gold -= 50;
						Saleboxwait = 0;
					}
				}
				else if (pplchoose == 3)
				{
					cgnd(msg);
					if (ischoose)
					{
						ischoose = false;
						people temp(choosex, choosey, 3, 100, Lewis, LewisY);
						peoples.push_back(temp);
						gold -= 150;
						Lewiswait = 0;
					}
				}
				else if (pplchoose == 4)
				{
					cgnd(msg);
					if (ischoose)
					{
						ischoose = false;
						people temp(choosex, choosey, 4, 5000, Boom, BoomY);
						peoples.push_back(temp);
						gold -= 300;
						Boomwait = 0;
					}
				}
				else if (pplchoose == 5)
				{
					cgnd(msg);
					if (ischoose)
					{
						ischoose = false;
						people temp(choosex, choosey, 5, 100, Sebastian, SebastianY);
						peoples.push_back(temp);
						gold -= 200;
						Sebastianwait = 0;
					}
				}
				else if (pplchoose == 6)
				{
					cgnd(msg);
					if (ischoose)
					{
						ischoose = false;
						people temp(choosex, choosey, 6, 5000, Block, BlockY);
						peoples.push_back(temp);
						gold -= 100;
						Blockwait = 0;
					}
				}
			}
			if (pauseflag)
			{
				FlushBatchDraw();
				Sleep(10);
				continue;
			}
			if (Camelliawait < 400)
			{
				Camelliawait++;
			}
			if (Saleboxwait < 400)
			{
				Saleboxwait++;
			}
			if (Lewiswait < 700)
			{
				Lewiswait++;
			}
			if (Boomwait < 2000)
			{
				Boomwait++;
			}
			if (Sebastianwait < 700)
			{
				Sebastianwait++;
			}
			if (Blockwait < 1000)
			{
				Blockwait++;
			}
			generatecoin();
			level3cnt++;  //第三关计数器
			if (level3cnt == 200 || level3cnt == 1200 || level3cnt == 2200 || level3cnt == 3200 || level3cnt == 4200 || level2cnt == 5200)
			{

				enemy e1(950, getrow(rand() % 5), 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
				enemies.push_back(e1);
			}
			if (level3cnt == 5500 || level3cnt == 6000)
			{
				enemy e1(950, getrow(rand() % 5), 2, 0.5, 3, 100, BlueSlime, BlueSlimeY, BlueSlimeSlow, BlueSlimeSlowY);
				enemies.push_back(e1);
			}
			if (level3cnt == 6500)
			{
				enemy e1(950, getrow(rand() % 5), 6, 0.8, 3, 50, Ghost, GhostY, GhostSlow, GhostSlowY);
				enemies.push_back(e1);
			}
			if (level3cnt == 7000)
			{
				enemy e1(950, getrow(rand() % 5), 5, 0.4, 3, 50, Skeleton, SkeletonY, SkeletonSlow, SkeletonSlowY);
				enemies.push_back(e1);
			}
			if (level3cnt >= 7500 && level3cnt <= 7800)
			{
				putimage(400, 300, &Wave);
			}
			if (level3cnt == 7900)
			{
				for (int i = 1; i <= 5; i++)
				{
					enemy e1(950, getrow(i), 1, 0.5, 3, 50, Slime3, Slime3Y, Slimeslow, SlimeslowY);
					enemies.push_back(e1);
				}
			}
			if (level3cnt == 8100)
			{
				enemy e1(950, getrow(rand() % 5), 2, 0.5, 3, 100, BlueSlime, BlueSlimeY, BlueSlimeSlow, BlueSlimeSlowY);
				enemy e2(950, getrow(rand() % 5 + 1), 5, 0.4, 3, 50, Skeleton, SkeletonY, SkeletonSlow, SkeletonSlowY);
				enemy e3(950, getrow(rand() % 5 + 2), 2, 0.5, 3, 100, BlueSlime, BlueSlimeY, BlueSlimeSlow, BlueSlimeSlowY);
				enemy e4(950, getrow(rand() % 5 + 3), 6, 0.8, 3, 50, Ghost, GhostY, GhostSlow, GhostSlowY);
				enemies.push_back(e1);
				enemies.push_back(e2);
				enemies.push_back(e3);
				enemies.push_back(e4);
			}
			if (level3cnt == 9100)
			{
				enemy e1(950, 215, 4, 0.3, 3, 150, BigSlime, BigSlimeY, BigSlimeSlow, BigSlimeSlowY);
				enemies.push_back(e1);
			}
			if (level3cnt == 9800)
			{
				for (int i = 1; i <= 3; i++)
				{
					enemy e1(950, getrow(rand() % 5 + i), 2, 0.5, 3, 100, BlueSlime, BlueSlimeY, BlueSlimeSlow, BlueSlimeSlowY);
					enemies.push_back(e1);
				}
			}
			if (level3cnt == 10500)
			{
				enemy e1(950, getrow(rand() % 5), 6, 0.8, 3, 50, Ghost, GhostY, GhostSlow, GhostSlowY);
				enemies.push_back(e1);
			}
			if (level3cnt >= 10800 && level3cnt <= 11100)
			{
				putimage(400, 300, &Wave);
			}
			if (level3cnt == 11200)
			{
				for (int i = 1; i <= 4; i++)
				{
					enemy e1(950, getrow(rand() % 5 + i), 2, 0.5, 3, 100, BlueSlime, BlueSlimeY, BlueSlimeSlow, BlueSlimeSlowY);
					enemies.push_back(e1);
				}
				enemy e2(950, getrow(rand() % 5), 3, 0.5, 3, 150, RedSlime, RedSlimeY, RedSlimeSlow, RedSlimeSlowY);
				enemies.push_back(e2);
			}
			if (level3cnt == 11350)
			{
				enemy e1(950, getrow(rand() % 5), 2, 0.5, 3, 100, BlueSlime, BlueSlimeY, BlueSlimeSlow, BlueSlimeSlowY);
				enemies.push_back(e1);
				enemy e2(950, 340, 4, 0.3, 3, 150, BigSlime, BigSlimeY, BigSlimeSlow, BigSlimeSlowY);
				enemies.push_back(e2);

			}
			if (level3cnt == 11500)
			{
				enemy e2(950, getrow(rand() % 5 + 1), 5, 0.4, 3, 50, Skeleton, SkeletonY, SkeletonSlow, SkeletonSlowY);
				enemies.push_back(e2);
			}
			if (level3cnt == 11600)
			{
				enemy e1(950, getrow(rand() % 5), 6, 0.8, 3, 50, Ghost, GhostY, GhostSlow, GhostSlowY);
				enemies.push_back(e1);
			}
			if (level3cnt >= 12600 && level3cnt <= 12900)
			{
				putimage(400, 300, &LastWave);
			}
			if (level3cnt == 13000)
			{
				enemy e1(950, 90, 4, 0.3, 3, 150, BigSlime, BigSlimeY, BigSlimeSlow, BigSlimeSlowY);
				enemies.push_back(e1);
				enemy e2(950, 340, 4, 0.3, 3, 150, BigSlime, BigSlimeY, BigSlimeSlow, BigSlimeSlowY);
				enemies.push_back(e2);
				enemy e3(950, 590, 4, 0.3, 3, 150, BigSlime, BigSlimeY, BigSlimeSlow, BigSlimeSlowY);
				enemies.push_back(e3);
			}
			if (level3cnt == 13150)
			{
				enemy e1(950, 215, 3, 0.5, 3, 150, RedSlime, RedSlimeY, RedSlimeSlow, RedSlimeSlowY);
				enemies.push_back(e1);
				enemy e2(950, 465, 3, 0.5, 3, 150, RedSlime, RedSlimeY, RedSlimeSlow, RedSlimeSlowY);
				enemies.push_back(e2);
			}
			if (level3cnt == 13300)
			{
				enemy e1(950, 215, 5, 0.4, 3, 50, Skeleton, SkeletonY, SkeletonSlow, SkeletonSlowY);
				enemies.push_back(e1);
				enemy e2(950, 465, 5, 0.4, 3, 50, Skeleton, SkeletonY, SkeletonSlow, SkeletonSlowY);
				enemies.push_back(e2);
			}
			if (level3cnt == 13400 || level3cnt == 13450 || level3cnt == 13500 || level3cnt == 13550 || level3cnt == 13600)
			{
				enemy e1(950, getrow(rand() % 5), 6, 0.8, 3, 50, Ghost, GhostY, GhostSlow, GhostSlowY);
				enemies.push_back(e1);
			}
			forpeople();
			if (kill >= 62)
			{
				Sleep(1000);
				putimage(0, 0, &Victory);
				FlushBatchDraw();
				peoples.clear();
				enemies.clear();
				bullets.clear();
				coins.clear();
				retu.isactive = false;
				flag = 1;
				winflag = 1;
				Sleep(3000);
				continue;
			}
			forbullet();
			forenemy();
			forcoin();
		}
		if (flag == 6)  //图鉴页面
		{
			putimage(0, 0, &Background);
			putimage(retu.x, retu.y, &retu.normal);
			putimage(200, 200, &CamelliaLOGOY, SRCAND);
			putimage(200, 200, &CamelliaLOGO, SRCPAINT);
			settextstyle(30, 8, _T("华文行楷"));
			outtextxy(200, 550, _T("友方单位图鉴"));
			putimage(650, 200, &SkeletonLOGOY, SRCAND);
			putimage(650, 200, &SkeletonLOGO, SRCPAINT);
			outtextxy(650, 550, _T("敌方单位图鉴"));
			retu.isactive = true;
			if (MouseHit())
			{
				MOUSEMSG msg = GetMouseMsg();
				if (IsMouseInButton(retu, msg))
				{
					if (msg.uMsg == WM_LBUTTONDOWN)
					{
						flag = 2;
						retu.isactive = false;
					}
				}
				if (msg.x >= 200 && msg.x <= 350 && msg.y >= 200 && msg.y <= 500 && msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 7;
				}
				if (msg.x >= 650 && msg.x <= 800 && msg.y >= 200 && msg.y <= 500 && msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 13;
				}
			}
		}
		if (flag == 7)  //flag7-12是六个友方图鉴页面
		{
			putimage(0, 0, &Background);
			putimage(retu.x, retu.y, &retu.normal);
			putimage(200, 200, &CamelliaLOGOY, SRCAND);
			putimage(200, 200, &CamelliaLOGO, SRCPAINT);
			putimage(900, 450, &Skip);
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(500, 200, _T("卡米莉亚"));
			settextstyle(30, 10, _T("Kristen ITC"));
			outtextxy(575, 200, _T("(Camellia)"));
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(500, 230, _T("发射防风草子弹攻击敌人"));
			outtextxy(500, 290, _T("每次攻击造成10点伤害"));
			outtextxy(500, 320, _T("攻击间隔为150时基单元（100时基单元约1秒）"));
			outtextxy(500, 350, _T("生命值：100"));
			outtextxy(500, 380, _T("部署花费：100金币"));
			outtextxy(500, 410, _T("冷却：500时基单元"));
			if (MouseHit())
			{
				MOUSEMSG msg = GetMouseMsg();
				if (IsMouseInButton(retu, msg))
				{
					if (msg.uMsg == WM_LBUTTONDOWN)
					{
						flag = 6;
						retu.isactive = false;
					}
				}
				if(msg.x >= 900 && msg.x <= 1000 && msg.y >= 450 && msg.y <= 500 && msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 8;
				}
			}
		}
		if (flag == 8)
		{
			putimage(0, 0, &Background);
			putimage(retu.x, retu.y, &retu.normal);
			putimage(200, 200, &SaleboxLOGO);
			putimage(900, 450, &Skip);
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(500, 200, _T("出货箱"));
			settextstyle(30, 10, _T("Kristen ITC"));
			outtextxy(555, 200, _T("(Salebox)"));
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(500, 230, _T("出售货物赚取金币"));
			outtextxy(500, 290, _T("每1500时基单元产生50金币（速度为自然掉落金币的1/2）"));
			outtextxy(500, 320, _T("生命值：100"));
			outtextxy(500, 350, _T("部署花费：50金币"));
			outtextxy(500, 380, _T("冷却：500时基单元"));
			if (MouseHit())
			{
				MOUSEMSG msg = GetMouseMsg();
				if (IsMouseInButton(retu, msg))
				{
					if (msg.uMsg == WM_LBUTTONDOWN)
					{
						flag = 6;
						retu.isactive = false;
					}
				}
				if (msg.x >= 900 && msg.x <= 1000 && msg.y >= 450 && msg.y <= 500 && msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 9;
				}
			}
		}
		if (flag == 9)
		{
			putimage(0, 0, &Background);
			putimage(retu.x, retu.y, &retu.normal);
			putimage(200, 200, &LewisLOGOY, SRCAND);
			putimage(200, 200, &LewisLOGO, SRCPAINT);
			putimage(900, 450, &Skip);
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(500, 200, _T("刘易斯"));
			settextstyle(30, 10, _T("Kristen ITC"));
			outtextxy(555, 200, _T("(Lewis)"));
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(500, 230, _T("发射松露油子弹"));
			outtextxy(500, 290, _T("每次攻击造成7点伤害"));
			outtextxy(500, 320, _T("攻击间隔为150时基单元"));
			outtextxy(500, 350, _T("松露油子弹会使被击中的敌人减速"));
			outtextxy(500, 380, _T("生命值：100"));
			outtextxy(500, 410, _T("部署花费：150金币"));
			outtextxy(500, 440, _T("冷却：700时基单元"));
			if (MouseHit())
			{
				MOUSEMSG msg = GetMouseMsg();
				if (IsMouseInButton(retu, msg))
				{
					if (msg.uMsg == WM_LBUTTONDOWN)
					{
						flag = 6;
						retu.isactive = false;
					}
				}
				if (msg.x >= 900 && msg.x <= 1000 && msg.y >= 450 && msg.y <= 500 && msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 10;
				}
			}
		}
		if (flag == 10)
		{
			putimage(0, 0, &Background);
			putimage(retu.x, retu.y, &retu.normal);
			putimage(200, 200, &BoomLOGOY, SRCAND);
			putimage(200, 200, &BoomLOGO, SRCPAINT);
			putimage(900, 450, &Skip);
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(500, 200, _T("炸弹"));
			settextstyle(30, 10, _T("Kristen ITC"));
			outtextxy(535, 200, _T("(Boom)"));
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(500, 230, _T("会发生爆炸，小心了！"));
			outtextxy(500, 290, _T("可以攻击到本行和上下两行的敌人，造成范围50点伤害"));
			outtextxy(500, 320, _T("不会被敌人攻击破坏"));
			outtextxy(500, 350, _T("部署花费：300金币"));
			outtextxy(500, 380, _T("冷却：2000时基单元"));
			if (MouseHit())
			{
				MOUSEMSG msg = GetMouseMsg();
				if (IsMouseInButton(retu, msg))
				{
					if (msg.uMsg == WM_LBUTTONDOWN)
					{
						flag = 6;
						retu.isactive = false;
					}
				}
				if (msg.x >= 900 && msg.x <= 1000 && msg.y >= 450 && msg.y <= 500 && msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 11;
				}
			}
		}
		if (flag == 11)
		{
			putimage(0, 0, &Background);
			putimage(retu.x, retu.y, &retu.normal);
			putimage(200, 200, &SebastianLOGOY, SRCAND);
			putimage(200, 200, &SebastianLOGO, SRCPAINT);
			putimage(900, 450, &Skip);
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(500, 200, _T("塞巴斯蒂安"));
			settextstyle(30, 10, _T("Kristen ITC"));
			outtextxy(595, 200, _T("(Sebastian)"));
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(500, 230, _T("使用青蛙攻击敌人"));
			outtextxy(500, 290, _T("每次攻击造成7点伤害"));
			outtextxy(500, 320, _T("攻击间隔为150时基单元"));
			outtextxy(500, 350, _T("可以一次攻击一整行的敌人"));
			outtextxy(500, 380, _T("生命值：100"));
			outtextxy(500, 410, _T("部署花费：200金币"));
			outtextxy(500, 440, _T("冷却：700时基单元"));
			if (MouseHit())
			{
				MOUSEMSG msg = GetMouseMsg();
				if (IsMouseInButton(retu, msg))
				{
					if (msg.uMsg == WM_LBUTTONDOWN)
					{
						flag = 6;
						retu.isactive = false;
					}
				}
				if (msg.x >= 900 && msg.x <= 1000 && msg.y >= 450 && msg.y <= 500 && msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 12;
				}
			}
		}
		if (flag == 12)
		{
			putimage(0, 0, &Background);
			putimage(retu.x, retu.y, &retu.normal);
			putimage(200, 200, &BlockLOGOY, SRCAND);
			putimage(200, 200, &BlockLOGO, SRCPAINT);
			putimage(900, 450, &Skip);
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(500, 200, _T("路障"));
			settextstyle(30, 10, _T("Kristen ITC"));
			outtextxy(535, 200, _T("(Block)"));
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(500, 230, _T("由木匠商店打造，可以阻拦敌人"));
			outtextxy(500, 290, _T("生命值：5000"));
			outtextxy(500, 320, _T("部署花费：100金币"));
			outtextxy(500, 350, _T("冷却：1000时基单元"));
			if (MouseHit())
			{
				MOUSEMSG msg = GetMouseMsg();
				if (IsMouseInButton(retu, msg))
				{
					if (msg.uMsg == WM_LBUTTONDOWN)
					{
						flag = 6;
						retu.isactive = false;
					}
				}
				if (msg.x >= 900 && msg.x <= 1000 && msg.y >= 450 && msg.y <= 500 && msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 6;
				}
			}
		}
		if (flag == 13)  //flag13-18是六个敌方图鉴页面
		{
			putimage(0, 0, &Background);
			putimage(retu.x, retu.y, &retu.normal);
			putimage(650, 200, &SlimeLOGOY, SRCAND);
			putimage(650, 200, &SlimeLOGO, SRCPAINT);
			putimage(900, 450, &Skip);
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(100, 200, _T("史莱姆"));
			settextstyle(30, 10, _T("Kristen ITC"));
			outtextxy(155, 200, _T("(Slime)"));
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(100, 230, _T("普通的史莱姆"));
			outtextxy(100, 290, _T("生命值：50"));
			outtextxy(100, 320, _T("攻击力：3点每时基单元"));
			outtextxy(100, 350, _T("移动速度：0.5单位长度每时基单元（路径总长900单位长度）"));
			outtextxy(100, 380, _T("在全部关卡出现"));
			if (MouseHit())
			{
				MOUSEMSG msg = GetMouseMsg();
				if (IsMouseInButton(retu, msg))
				{
					if (msg.uMsg == WM_LBUTTONDOWN)
					{
						flag = 6;
						retu.isactive = false;
					}
				}
				if (msg.x >= 900 && msg.x <= 1000 && msg.y >= 450 && msg.y <= 500 && msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 14;
				}
			}
		}
		if (flag == 14)
		{
			putimage(0, 0, &Background);
			putimage(retu.x, retu.y, &retu.normal);
			putimage(650, 200, &BlueSlimeLOGOY, SRCAND);
			putimage(650, 200, &BlueSlimeLOGO, SRCPAINT);
			putimage(900, 450, &Skip);
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(100, 200, _T("蓝色史莱姆"));
			settextstyle(30, 10, _T("Kristen ITC"));
			outtextxy(195, 200, _T("(Blue Slime)"));
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(100, 230, _T("蓝色的史莱姆，生命值是普通史莱姆的两倍"));
			outtextxy(100, 290, _T("生命值：100"));
			outtextxy(100, 320, _T("攻击力：3点每时基单元"));
			outtextxy(100, 350, _T("移动速度：0.5单位长度每时基单元"));
			outtextxy(100, 380, _T("在第2、第3关卡出现"));
			if (MouseHit())
			{
				MOUSEMSG msg = GetMouseMsg();
				if (IsMouseInButton(retu, msg))
				{
					if (msg.uMsg == WM_LBUTTONDOWN)
					{
						flag = 6;
						retu.isactive = false;
					}
				}
				if (msg.x >= 900 && msg.x <= 1000 && msg.y >= 450 && msg.y <= 500 && msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 15;
				}
			}
		}
		if (flag == 15)
		{
			putimage(0, 0, &Background);
			putimage(retu.x, retu.y, &retu.normal);
			putimage(650, 200, &RedSlimeLOGOY, SRCAND);
			putimage(650, 200, &RedSlimeLOGO, SRCPAINT);
			putimage(900, 450, &Skip);
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(100, 200, _T("红色史莱姆"));
			settextstyle(30, 10, _T("Kristen ITC"));
			outtextxy(195, 200, _T("(Blue Slime)"));
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(100, 230, _T("红色的史莱姆，生命值是普通史莱姆的三倍"));
			outtextxy(100, 290, _T("生命值：150"));
			outtextxy(100, 320, _T("攻击力：3点每时基单元"));
			outtextxy(100, 350, _T("移动速度：0.5单位长度每时基单元"));
			outtextxy(100, 380, _T("在第2、第3关卡出现"));
			if (MouseHit())
			{
				MOUSEMSG msg = GetMouseMsg();
				if (IsMouseInButton(retu, msg))
				{
					if (msg.uMsg == WM_LBUTTONDOWN)
					{
						flag = 6;
						retu.isactive = false;
					}
				}
				if (msg.x >= 900 && msg.x <= 1000 && msg.y >= 450 && msg.y <= 500 && msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 16;
				}
			}
		}
		if (flag == 16)
		{
			putimage(0, 0, &Background);
			putimage(retu.x, retu.y, &retu.normal);
			putimage(650, 200, &BigSlimeLOGOY, SRCAND);
			putimage(650, 200, &BigSlimeLOGO, SRCPAINT);
			putimage(900, 450, &Skip);
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(100, 200, _T("大史莱姆"));
			settextstyle(30, 10, _T("Kristen ITC"));
			outtextxy(175, 200, _T("(Big Slime)"));
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(100, 230, _T("巨大的史莱姆，生命值是普通史莱姆的三倍，但移动速度慢"));
			outtextxy(100, 290, _T("被击败时会释放出4个普通史莱姆，本行2个，上下2行各一个"));
			outtextxy(100, 320, _T("特别的，如果处于第一行或第五行，则只会释放出3个"));
			outtextxy(100, 350, _T("生命值：150"));
			outtextxy(100, 380, _T("攻击力：3点每时基单元"));
			outtextxy(100, 410, _T("移动速度：0.3单位长度每时基单元"));
			outtextxy(100, 440, _T("在第3关卡出现"));
			if (MouseHit())
			{
				MOUSEMSG msg = GetMouseMsg();
				if (IsMouseInButton(retu, msg))
				{
					if (msg.uMsg == WM_LBUTTONDOWN)
					{
						flag = 6;
						retu.isactive = false;
					}
				}
				if (msg.x >= 900 && msg.x <= 1000 && msg.y >= 450 && msg.y <= 500 && msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 17;
				}
			}
		}
		if (flag == 17)
		{
			putimage(0, 0, &Background);
			putimage(retu.x, retu.y, &retu.normal);
			putimage(650, 200, &SkeletonLOGOY, SRCAND);
			putimage(650, 200, &SkeletonLOGO, SRCPAINT);
			putimage(900, 450, &Skip);
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(100, 200, _T("骷髅"));
			settextstyle(30, 10, _T("Kristen ITC"));
			outtextxy(135, 200, _T("(Skeleton)"));
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(100, 230, _T("会投掷骨头来进行攻击"));
			outtextxy(100, 290, _T("每个骨头会造成50点伤害"));
			outtextxy(100, 320, _T("投掷骨头的时间是随机的，但平均每800时基单元一次"));
			outtextxy(100, 350, _T("生命值：50"));
			outtextxy(100, 380, _T("攻击力：3点每时基单元"));
			outtextxy(100, 410, _T("移动速度：0.4单位长度每时基单元"));
			outtextxy(100, 440, _T("在第3关卡出现"));
			if (MouseHit())
			{
				MOUSEMSG msg = GetMouseMsg();
				if (IsMouseInButton(retu, msg))
				{
					if (msg.uMsg == WM_LBUTTONDOWN)
					{
						flag = 6;
						retu.isactive = false;
					}
				}
				if (msg.x >= 900 && msg.x <= 1000 && msg.y >= 450 && msg.y <= 500 && msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 18;
				}
			}
		}
		if (flag == 18)
		{
			putimage(0, 0, &Background);
			putimage(retu.x, retu.y, &retu.normal);
			putimage(650, 200, &GhostLOGOY, SRCAND);
			putimage(650, 200, &GhostLOGO, SRCPAINT);
			putimage(900, 450, &Skip);
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(100, 200, _T("幽灵"));
			settextstyle(30, 10, _T("Kristen ITC"));
			outtextxy(135, 200, _T("(Ghost)"));
			settextstyle(30, 6.5, _T("华文行楷"));
			outtextxy(100, 230, _T("运动敏捷，但生命值不高"));
			outtextxy(100, 290, _T("移动速度快， 且会在各行之间随机平行移动"));
			outtextxy(100, 320, _T("发生移动的时间是随机的，但平均每800时基单元一次"));
			outtextxy(100, 350, _T("生命值：50"));
			outtextxy(100, 380, _T("攻击力：3点每时基单元"));
			outtextxy(100, 410, _T("移动速度：0.8单位长度每时基单元"));
			outtextxy(100, 440, _T("在第3关卡出现"));
			if (MouseHit())
			{
				MOUSEMSG msg = GetMouseMsg();
				if (IsMouseInButton(retu, msg))
				{
					if (msg.uMsg == WM_LBUTTONDOWN)
					{
						flag = 6;
						retu.isactive = false;
					}
				}
				if (msg.x >= 900 && msg.x <= 1000 && msg.y >= 450 && msg.y <= 500 && msg.uMsg == WM_LBUTTONDOWN)
				{
					flag = 6;
				}
			}
		}
		FlushBatchDraw();
		Sleep(10); 
	}
	system("pause"); 
	closegraph(); 
	return 0; 
}
